"""
del语句和垃圾回收

Python中垃圾回收的算法是采用引用计数。
"""


def use_delete():
    x = 1
    y = x
    del x
    print(y)
    # 输出结果：
    """
    y
    """

    try:
        print(x)
    except Exception as e:
        print(type(e))
    # 输出结果：
    """
    <class 'UnboundLocalError'>
    """


if __name__ == '__main__':
    use_delete()
